/**
 * Created by Administrator on 2017/4/1.
 */
"use strict";
swan_pc
    .controller("OrgOppBaseController",function($scope,$rootScope,$state,oppBase) {
        $scope.getInfo=function () {
            oppBase.get({id:$rootScope.opp.id},function (result) {
                $scope.selectInfo=result;
                console.log("iNFO",$scope.selectInfo);
                $scope.infoPointer={
                    base:$scope.selectInfo,
                    forceBase:$scope.selectInfo.impose,
                    forceGood:$scope.selectInfo.impose.good,
                    forceBad:$scope.selectInfo.impose.bad,
                    financeBase:$scope.selectInfo.financeDTO,
                    financeList:$scope.selectInfo.financeDTO.budgetList,
                    requireBase:$scope.selectInfo.requirementDTO,
                    requireBid:$scope.selectInfo.requirementDTO.directQualifications,
                };
                $scope.setStruct();
            })
        }

        $scope.setAllList=function () {

            $scope.statusList=[
                {
                    name:'真在进行',
                    value:1
                },
                {
                    name:'胜利',
                    value:2
                },
                {
                    name:'失败',
                    value:3
                },
                {
                    name:'没有希望',
                    value:4
                },
                {
                    name:'已取消',
                    value:5
                },
                {
                    name:'关闭',
                    value:6
                },
            ]
            $scope.stateList=[
                {
                    name:'策划',
                    value:1
                },
                {
                    name:'准备',
                    value:2
                },
                {
                    name:'招标',
                    value:3
                },
                {
                    name:'评标',
                    value:4
                },
                {
                    name:'谈判',
                    value:5
                },
                {
                    name:'交付',
                    value:6
                },
            ];
            $scope.participateList=[
                {
                    name:'自有产品投标',
                    value:1
                },
                {
                    name:'代理产品投标',
                    value:2
                },
                {
                    name:'自有产品同时代理产品投标',
                    value:3
                },
                {
                    name:'供应产品不直接投标',
                    value:4
                },
                {
                    name:'中间过手',
                    value:5
                }
            ];
            $scope.tenderList=[
                {
                    name:'邀标',
                    value:1
                },
                {
                    name:'公开招标',
                    value:2
                },
                {
                    name:'竞争性谈判',
                    value:3
                },
                {
                    name:'单一来源采购',
                    value:4
                },
                {
                    name:'上级单位招标',
                    value:5
                },
                {
                    name:'询价',
                    value:6
                },
            ];
            $scope.progressList=[
                {
                    name:'线索',
                    value:0
                },
                {
                    name:'项目机会',
                    value:1
                }
            ];
            $scope.urgencyList=[
                {
                    name:'很紧急',
                    value:1
                },
                {
                    name:'紧急',
                    value:2
                },
                {
                    name:'正常',
                    value:3
                },
                {
                    name:'遥远',
                    value:4
                },
            ];
            $scope.reasonList=[
                {
                    name:'最高层支持',
                    value:1
                },
                {
                    name:'明显改善运营或管理',
                    value:2
                },
                {
                    name:'合规',
                    value:4
                },
                {
                    name:'国家政策',
                    value:8
                },
                {
                    name:'业务需要',
                    value:16
                },
                {
                    name:'生产需要',
                    value:32
                },
                {
                    name:'国家项目',
                    value:64
                },
                {
                    name:'监管需要',
                    value:128
                },
            ];
            $scope.resultList=[
                {
                    name:'公司错失发展机会',
                    value:1
                },
                {
                    name:'公司发展有影响',
                    value:2
                },
                {
                    name:'年度预算将被收回',
                    value:3
                },
                {
                    name:'耽误重大活动',
                    value:4
                },
                {
                    name:'后续重大项目无法开展',
                    value:5
                },
                {
                    name:'项目再次拖延',
                    value:6
                },
                {
                    name:'领导仕途受到影响',
                    value:7
                }
            ];
            $scope.financeList=[
                {
                    name:'好',
                    value:1
                },
                {
                    name:'不好',
                    value:2
                },
                {
                    name:'不确定',
                    value:3
                }
            ];
            $scope.trendList=[
                {
                    name:'转好',
                    value:1
                },
                {
                    name:'转坏',
                    value:2
                },
                {
                    name:'维持',
                    value:3
                },
                {
                    name:'不确定',
                    value:4
                }
            ];
            $scope.budgetList=[
                {
                    name:'有',
                    value:1
                },
                {
                    name:'没有',
                    value:2
                },
                {
                    name:'不确定',
                    value:3
                }
            ]
            $scope.industryList=[
                {
                    name:'朝阳产业',
                    value:1
                },
                {
                    name:'红海',
                    value:2
                },
                {
                    name:'不确定',
                    value:3
                }
            ];
            $scope.assuranceList=[
                {
                    name:'能',
                    value:1
                },
                {
                    name:'不能',
                    value:2
                },
                {
                    name:'可能',
                    value:3
                },
                {
                    name:'勉强',
                    value:4
                },
                {
                    name:'不确定',
                    value:5
                }
            ];
            $scope.monthList=[
                {
                    name:'一月',
                    value:1
                },
                {
                    name:'二月',
                    value:2
                },
                {
                    name:'三月',
                    value:3
                },
                {
                    name:'四月',
                    value:4
                },
                {
                    name:'五月',
                    value:5
                },
                {
                    name:'六月',
                    value:6
                },
                {
                    name:'七月',
                    value:7
                },
                {
                    name:'八月',
                    value:8
                },
                {
                    name:'九月',
                    value:9
                },
                {
                    name:'十月',
                    value:10
                },
                {
                    name:'十一月',
                    value:11
                },
                {
                    name:'十二月',
                    value:12
                },
            ];
            $scope.understandList=[
                {
                    name:'了解',
                    value:1
                },
                {
                    name:'部分了解',
                    value:2
                },
                {
                    name:'不了解',
                    value:3
                }
            ];
            $scope.benefitList=[
                {
                    name:'有利',
                    value:1
                },
                {
                    name:'部分有利',
                    value:2
                },
                {
                    name:'不利',
                    value:3
                }
            ];
            $scope.whoList=[
                {
                    name:'我方',
                    value:1
                },
                {
                    name:'对手',
                    value:2
                },
                {
                    name:'客户',
                    value:3
                },
                {
                    name:'其他',
                    value:4
                },
            ];
        };
        $scope.setAllList();
        $scope.getInfo();

        $scope.setStruct=function () {
            $scope.baseStruct=[
                {
                    blockName:'基本信息',
                    blockKey:'base',
                    type:'normal',
                    list:[],
                    struct:[
                        {
                            name:'项目名称',
                            key:'name',
                            type:1,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'项目代码',
                            key:'code',
                            type:1,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'客户名称',
                            key:'orgCustomerName',
                            type:1,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'金额',
                            key:'amount',
                            type:1,
                            preText:'',
                            afterText:'万元',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'跟踪进展',
                            key:'progress',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.progressList,
                            numInRow:2,
                        },
                        {
                            name:'胜率',
                            key:'rate',
                            type:1,
                            preText:'',
                            afterText:'%',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'状态',
                            key:'status',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.statusList,
                            numInRow:2,
                        },
                        {
                            name:'承诺按时进单',
                            key:'promise',
                            type:5,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'项目阶段',
                            key:'state',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.stateList,
                            numInRow:2,
                        },
                        {
                            name:'招标方式',
                            key:'tender',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.tenderList,
                            numInRow:2,
                        },
                        {
                            name:'参与方式',
                            key:'participate',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.participateList,
                            numInRow:2,
                        }
                    ]
                },
                {
                    blockName:'用户问题',
                    blockKey:'base',
                    type:'normal',
                    list:[],
                    struct:[
                        {
                            name:'问题说明',
                            key:'description',
                            type:6,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:1,
                        },
                    ]
                },
                {
                    blockName:'强制机制',
                    blockKey:'forceBase',
                    type:'normal',
                    list:[],
                    struct:[
                        {
                            name:'紧张程度',
                            key:'urgency',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.urgencyList,
                            numInRow:2,
                        },
                        {
                            name:'迫使用户行动原因',
                            key:'reason',
                            type:3,
                            preText:'',
                            afterText:'',
                            select:$scope.reasonList,
                            numInRow:2,
                        },
                        {
                            name:'强制机制说明',
                            key:'imposeDescription',
                            type:1,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'上线截止日期',
                            key:'date',
                            type:1,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                        {
                            name:'不行动后果',
                            key:'result',
                            type:2,
                            preText:'',
                            afterText:'',
                            select:$scope.resultList,
                            numInRow:2,
                        },
                        {
                            name:'后果说明',
                            key:'resultDescription',
                            type:1,
                            preText:'',
                            afterText:'',
                            select:[],
                            numInRow:2,
                        },
                    ]
                },
                {
                    blockName: '实施后好处量化说明',
                    blockKey: 'forceGood',
                    type: 'block',
                    list: [],
                    struct: [
                        {
                            name: '营业额提升',
                            key: 'turnover',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '运营费用',
                            key: 'opEx',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '利润',
                            key: 'profit',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '员工数量',
                            key: 'employee',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '成本',
                            key: 'cost',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                    ]
                },
                {
                    blockName: '未实施后坏处量化说明',
                    blockKey: 'forceBad',
                    type: 'block',
                    list: [],
                    struct: [
                        {
                            name: '营业额下降',
                            key: 'turnover',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '运营费用',
                            key: 'opEx',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '利润',
                            key: 'profit',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '员工数量',
                            key: 'employee',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '成本',
                            key: 'cost',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        },
                    ]
                },
                {
                    blockName: '财务',
                    blockKey: 'financeBase',
                    type: 'normal',
                    list: [],
                    struct: [
                        {
                            name: '客户财政状况',
                            key: 'finance',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.financeList,
                            numInRow: 2,
                        },
                        {
                            name: '趋势',
                            key: 'trend',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.trendList,
                            numInRow: 2,
                        },
                        {
                            name: '产业',
                            key: 'industry',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.industryList,
                            numInRow: 2,
                        },
                        {
                            name: '项目是否有预算',
                            key: 'finance',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.financeList,
                            numInRow: 2,
                        },
                        {
                            name: '客户财政状况',
                            key: 'budget',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.budgetList,
                            numInRow: 2,
                        },
                        {
                            name: '预算金额',
                            key: 'budgetAmount',
                            type: 1,
                            preText: '',
                            afterText: '万元',
                            select:[],
                            numInRow: 2,
                        },
                        {
                            name: '保证质量',
                            key: 'assurance',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.assuranceList,
                            numInRow: 2,
                        },
                        {
                            name: '下一年度预算月份',
                            key: 'month',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.monthList,
                            numInRow: 2,
                        },
                        {
                            name: '客户预算过程',
                            key: 'process',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 2,
                        },
                    ]
                },
                {
                    blockName: '总的预算还包含的部分',
                    blockKey: 'financeList',
                    type: 'repeat',
                    list: [],
                    struct: [
                        {
                            name: '预算名称',
                            key: 'name',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '预算金额',
                            key: 'amount',
                            type: 1,
                            preText: '',
                            afterText: '万元',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name: '预算所占比例',
                            key: 'rate',
                            type: 1,
                            preText: '',
                            afterText: '%',
                            select: [],
                            numInRow: 2,
                        }
                    ]
                },
                {
                    blockName: '要求',
                    blockKey: 'requireBase',
                    type: 'normal',
                    list: [],
                    struct: [
                        {
                            name: '功能上的要求了解程度',
                            key: 'functionU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name: '功能要求有利于我们的产品',
                            key: 'functionB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name: '具体功能上的要求',
                            key: 'functionR',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '性能上的要求了解程度',
                            key: 'performU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name: '性能要求有利于我们的产品',
                            key: 'performB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name: '具体性能上的要求',
                            key: 'performR',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '技术实现上的要求了解程度',
                            key: 'techniqueU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name: '技术实现要求有利于我们的产品',
                            key: 'techniqueB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name: '具体技术实现上的要求',
                            key: 'techniqueR',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name:'商务上的要求了解程度',
                            key:'businessU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name:'商务要求有利于我们的产品',
                            key:'businessB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name:'具体商务上的要求',
                            key:'businessR',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name:'政治上的要求了解程度',
                            key:'politicsU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name:'政治要求有利于我们的产品',
                            key:'politicsB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name:'具体政治上的要求',
                            key:'politicsR',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name:'培训上的要求了解程度',
                            key:'trainU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name:'培训要求有利于我们的产品',
                            key:'trainB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name:'具体培训上的要求',
                            key:'trainR',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name:'其他要求了解程度',
                            key:'otherU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.understandList,
                            numInRow: 2,
                        },
                        {
                            name:'其他有利于产品',
                            key:'otherB',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name:'其他上的要求',
                            key:'otherD',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name: '',
                            key: '',
                            type: 0,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                        {
                            name:'谁确定指标参数',
                            key:'who',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.whoList,
                            numInRow: 2,
                        },
                        {
                            name:'谁确定指标参数',
                            key:'qualificationU',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                        {
                            name:'具体说明',
                            key:'whoD',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select:[],
                            numInRow: 1,
                        },
                    ]
                },
                {
                    blockName: '对直接投标者的资质要求',
                    blockKey: 'requireBid',
                    type: 'repeat',
                    list: [],
                    struct: [
                        {
                            name:'具体要求',
                            key:'name',
                            type: 1,
                            preText: '',
                            afterText: '',
                            select: [],
                            numInRow: 2,
                        },
                        {
                            name:'是否有利于我们',
                            key:'benefit',
                            type: 2,
                            preText: '',
                            afterText: '',
                            select:$scope.benefitList,
                            numInRow: 2,
                        },
                    ]
                }
            ]
        }

    });
